package com.saifan.wyy_ov.utils;

import java.math.BigDecimal;

/**
 * @author WangLi
 * @date 2015年4月1日 下午5:45:44
 * @Description 得到价格
 * @version V1.0
 */

public class PriceUtils {
	public static String getPrice(String price){
		try {
			if(price!=null&&!price.equals("")){
				BigDecimal rateDecimal = new BigDecimal(Double.valueOf(price));
				BigDecimal  num=rateDecimal.setScale(2, BigDecimal.ROUND_HALF_UP);//四舍五入
				return String.valueOf(num);
			}else {
				return  "0.00";
			}
		}catch ( NumberFormatException e){
			LogUtil.e(e);
			return  "0.00";
		}


	}
	
	public static String getPrice(int price){
		BigDecimal rateDecimal = new BigDecimal(Double.valueOf(price));
		BigDecimal  num=rateDecimal.setScale(2, BigDecimal.ROUND_HALF_UP);//四舍五入
		return String.valueOf(num);
	}
	public static String getPrice(Double price){
		BigDecimal rateDecimal = new BigDecimal(Double.valueOf(price));
		BigDecimal  num=rateDecimal.setScale(2, BigDecimal.ROUND_HALF_UP);//四舍五入
		return String.valueOf(num);
	}
	public static String getPrice(Float price){
		BigDecimal rateDecimal = new BigDecimal(Double.valueOf(price));
		BigDecimal  num=rateDecimal.setScale(2, BigDecimal.ROUND_HALF_UP);//四舍五入
		return String.valueOf(num);
	}
}
